package com.ruoyi.project.WebMoudle.carouselSeat.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.WebMoudle.carouselSeat.domain.CarouselSeat;
import com.ruoyi.project.WebMoudle.carouselSeat.service.ICarouselSeatService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 轮播位置Controller
 * 
 * @author ruoyi
 * @date 2020-07-06
 */
@Controller
@RequestMapping("/carouselSeat/carouselSeat")
public class CarouselSeatController extends BaseController
{
    private String prefix = "carouselSeat/carouselSeat";

    @Autowired
    private ICarouselSeatService carouselSeatService;

    @RequiresPermissions("carouselSeat:carouselSeat:view")
    @GetMapping()
    public String carouselSeat()
    {
        return prefix + "/carouselSeat";
    }

    /**
     * 查询轮播位置列表
     */
    @RequiresPermissions("carouselSeat:carouselSeat:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CarouselSeat carouselSeat)
    {
        startPage();
        List<CarouselSeat> list = carouselSeatService.selectCarouselSeatList(carouselSeat);
        return getDataTable(list);
    }

    /**
     * 导出轮播位置列表
     */
    @RequiresPermissions("carouselSeat:carouselSeat:export")
    @Log(title = "轮播位置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CarouselSeat carouselSeat)
    {
        List<CarouselSeat> list = carouselSeatService.selectCarouselSeatList(carouselSeat);
        ExcelUtil<CarouselSeat> util = new ExcelUtil<CarouselSeat>(CarouselSeat.class);
        return util.exportExcel(list, "carouselSeat");
    }

    /**
     * 新增轮播位置
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存轮播位置
     */
    @RequiresPermissions("carouselSeat:carouselSeat:add")
    @Log(title = "轮播位置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CarouselSeat carouselSeat)
    {
        return toAjax(carouselSeatService.insertCarouselSeat(carouselSeat));
    }

    /**
     * 修改轮播位置
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CarouselSeat carouselSeat = carouselSeatService.selectCarouselSeatById(id);
        mmap.put("carouselSeat", carouselSeat);
        return prefix + "/edit";
    }

    /**
     * 修改保存轮播位置
     */
    @RequiresPermissions("carouselSeat:carouselSeat:edit")
    @Log(title = "轮播位置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CarouselSeat carouselSeat)
    {
        return toAjax(carouselSeatService.updateCarouselSeat(carouselSeat));
    }

    /**
     * 删除轮播位置
     */
    @RequiresPermissions("carouselSeat:carouselSeat:remove")
    @Log(title = "轮播位置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(carouselSeatService.deleteCarouselSeatByIds(ids));
    }

    /**
     * 广告位号是否重复
     */
    @PostMapping("/checkNumUnique")
    @ResponseBody
    public String checkNumUnique(CarouselSeat carouselSeat)
    {
        return carouselSeatService.checkNumUnique(carouselSeat);
    }
}
